<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // list是打开过的盒子 dataList是打开的没打开过的都在里面 需求让总盒子打开过的那一项show 变为true 没打开的为false
        let dataList=[
        {
            id:'0',
            pid:'1',
            name:'盲盒1'
        },
        {
            id:'1',
            pid:'2',
            name:'盲盒2'
        },
        {
            id:'2',
            pid:'3',
            name:'盲盒3'
        }
    ]
  let  list=['1','2'] //代表id 位1 和 2的盲盒打开了 
let newList=dataList.map(item=>({
    ...item,
    isShow:false
}))
console.log(newList) //现在是先给dataList添加isShow属性

newList.forEach(item=>{
    list.forEach(ele=>{
        if(item.id==ele){
            item.isShow=true
        }
    })
})
console.log(newList) //这是最后打开后的盒子新数组
    </script>
</body>
</html>